package JavaShengSai;

import java.util.Scanner;

/**
 * 19. 寻找2020
 * https://www.lanqiao.cn/problems/1065/learning/?page=1&first_category_id=1&tags=2020,%E7%9C%81%E8%B5%9B&tag_relation=intersection&sort=pass_rate&asc=0
 */
public class Main20 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
         char[][] ch = new char[300][300];
         int count = 0;
         for(int i = 0;i < ch.length;i++) {
           ch[i] = scan.nextLine().toCharArray();
         }
         // 行
         for(int i = 0;i < ch.length;i++) {
           for(int j = 0;j < ch[i].length - 3;j++) {
             if(ch[i][j] == '2' && ch[i][j + 1] == '0' && ch[i][j + 2] == '2' && ch[i][j + 3] == '0') {
               count++;
             }
           }
         }

         // 列
         for(int i = 0;i < ch.length - 3;i++) {
           for(int j = 0;j < ch[i].length;j++) {
             if(ch[i][j] == '2' && ch[i + 1][j] == '0' && ch[i + 2][j] == '2' && ch[i + 3][j] == '0') {
               count++;
             }
           }
         }

         // 对角线
         for(int i = 0;i < ch.length - 3;i++) {
           for(int j = 0;j < ch[i].length - 3;j++) {
             if(ch[i][j] == '2' && ch[i + 1][j + 1] == '0' && ch[i + 2][j + 2] == '2' && ch[i + 3][j + 3] == '0') {
               count++;
             }
           }
         }
         System.out.println(count);
//        System.out.println(16520);
        scan.close();
    }
}
